package com.fesine.quartz.chapter7;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.JobListener;

/**
 * @description: 类描述
 * @author: Fesine
 * @createTime:2016/11/19 20:40
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2016/11/19 20:40
 */
public class SimpleJobListener implements JobListener {

    Log logger = LogFactory.getLog(SimpleJobListener.class);

    //private String name;
    @Override
    public String getName() {
        return getClass().getSimpleName();
    }

    //public void setName(String name) {
    //    this.name=name;
    //}

    @Override
    public void jobToBeExecuted(JobExecutionContext context) {
        String jobName = context.getJobDetail().getName();
        logger.info(jobName + " is about to be executed.");
    }

    @Override
    public void jobExecutionVetoed(JobExecutionContext context) {
        String jobName = context.getJobDetail().getName();
        logger.info(jobName + " was vetoed and not executed.");
    }

    @Override
    public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) {
        String jobName = context.getJobDetail().getName();
        logger.info(jobName + " was executed.");
    }
}
